# 小米笔试 - 数组分割问题
import sys
def solve():
    def partition_array(n, k, arr):
        # dp[i][j] 表示将前i个元素分割成j个子数组的最小差值
        # 同时记录分割方案
        INF = float('inf')
        
        # 预处理：计算区间[i,j]的最大值
        max_val = [[0] * n for _ in range(n)]
        for i in range(n):
            for j in range(i, n):
                if i == j:
                    max_val[i][j] = arr[i]
                else:
                    max_val[i][j] = max(max_val[i][j-1], arr[j])
        
        # dp[i][j] = (min_diff, partition_scheme)
        dp = [[(INF, []) for _ in range(k+1)] for _ in range(n+1)]
        
        # 初始化：分割成1个子数组的情况
        for i in range(1, n+1):
            dp[i][1] = (0, [(1, i)])  # 差值为0，因为只有一个子数组
        
        # 状态转移
        for i in range(1, n+1):  # 前i个元素
            for j in range(2, min(i+1, k+1)):  # 分割成j个子数组
                for t in range(j-1, i):  # 最后一个子数组从t+1到i
                    # 计算最后一个子数组的最大值
                    last_max = max_val[t][i-1]
                    
                    # 计算前t个元素分割成j-1个子数组的最大值和最小值
                    if dp[t][j-1][0] == INF:
                        continue
                    
                    prev_scheme = dp[t][j-1][1]
                    if not prev_scheme:
                        continue
                    
                    # 计算前j-1个子数组的最大值和最小值
                    prev_maxs = []
                    for start, end in prev_scheme:
                        prev_maxs.append(max_val[start-1][end-1])
                    
                    # 添加当前子数组的最大值
                    all_maxs = prev_maxs + [last_max]
                    current_diff = max(all_maxs) - min(all_maxs)
                    
                    # 更新dp
                    if current_diff < dp[i][j][0] or \
                       (current_diff == dp[i][j][0] and 
                        (not dp[i][j][1] or 
                         (t+1, i) < dp[i][j][1][-1])):
                        new_scheme = prev_scheme + [(t+1, i)]
                        dp[i][j] = (current_diff, new_scheme)
        
        return dp[n][k][1]
    
    # 读取输入
    T = int(input()) #读取测试用例的数量
    for _ in range(T):
        n, k = map(int, input().split()) #读取第二行的数字，也就是n和k
        arr = list(map(int, input().split())) #读取第三行的数字，也就是arr
        
        # 解决问题
        result = partition_array(n, k, arr)
        
        # 输出结果
        for start, end in result:
            print(start, end)

if __name__ == "__main__":
    solve()